﻿using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using UnityEngine;

public class RandomInstantiate : MonoBehaviour
{
    [CompilerGenerated]
    private static Func<Setting, float> <>f__am$cache1;
    public List<Setting> settings = new List<Setting>();

    public virtual List<Transform> DoInstantiate()
    {
        if (<>f__am$cache1 == null)
        {
            <>f__am$cache1 = x => x.probability;
        }
        Setting randomElementByWeight = this.settings.GetRandomElementByWeight<Setting>(<>f__am$cache1);
        List<Transform> list = new List<Transform>();
        if (randomElementByWeight != null)
        {
            for (int i = 0; i < randomElementByWeight.count; i++)
            {
                if (UnityEngine.Random.Range((float) 0f, (float) 1f) < randomElementByWeight.probability)
                {
                    Transform item = UnityEngine.Object.Instantiate<Transform>(randomElementByWeight.prefab);
                    item.transform.position = base.transform.position;
                    list.Add(item);
                }
            }
        }
        return list;
    }

    [Serializable]
    public class Setting
    {
        public int count = 1;
        public Transform prefab;
        public float probability = 1f;
    }
}

